<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="renderer" content="webkit">
  		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title>MY_PRO</title>
		<link rel="stylesheet" type="text/css" th:href="@{static/admin/layui/css/layui.css}"/>
		<link rel="stylesheet" type="text/css" th:href="@{static/admin/css/admin.css}"/>
	</head>
	<body>
	<form class="layui-form column-content-detail">
						<div class="layui-content">
							<div class="layui-tab-item layui-show">
								<div class="layui-form-item">
									<label class="layui-form-label">用户名：</label>
									<div class="layui-input-block">
										<input type="hidden" name="id"  class="layui-input" th:value="" >
										<input type="text" name="name" required lay-verify="required" class="layui-input" th:value="" >
									</div>
								</div>
								<div class="layui-form-item">
									<label class="layui-form-label">密码：</label>
									<div class="layui-input-block">
										<input type="text" name="password" required lay-verify="required"  class="layui-input" th:value="" >
									</div>
								</div>
							</div>
						</div>
					<div class="layui-form-item" style="padding-left: 10px;">
						<div class="layui-input-block">
							<button class="layui-btn layui-btn-normal" lay-submit lay-filter="submit">立即提交</button>
							<button type="reset" class="layui-btn layui-btn-primary">重置</button>
						</div>
					</div>
				</form>

	<script th:src="@{static/admin/lib/jquery/jquery.min.js}"></script>
	<script th:src="@{static/admin/layui/layui.js}" ></script>
	<script th:src="@{static/admin/js/core.js}"></script>
	<script>
		layui.use(['form', 'jquery', 'laydate', 'layer', 'laypage'], function() {
			var form = layui.form,
				layer = layui.layer;
			//监听提交
			form.on('submit(submit)', function(data) {
				if(data.field.status == "on") {
					data.field.status = "1";
				} else {
					data.field.status = "0";
				}
				$.ajax({
					type: "POST",
					url: ("/saveOrUpdateUser").replace('//', '/'),
					data:data.field,
					dataType: "json",
					success: function (data) {
						if (data.status == 200) {
							layer.msg(data.msg, {
								offset: '30%',
								time: 800
							}, function () {
								//调用父页面的刷新
								window.parent.refresh();
							});
						}else{
							layer.msg(data.msg, {
								icon: 2,
								offset: '30%',
								time: 2000
							});
						}
					}
				});
				return false;
			});

			//全选
				form.on('checkbox(allChoose)', function(data) {
					var child = $(data.elem).parents('table').find('tbody input[type="checkbox"]');
					child.each(function(index, item) {
						item.checked = data.elem.checked;
					});
					form.render('checkbox');
				});
				form.render();

			});



	</script>
	</body>
</html>